<?php
    include_once '../server/config/IApplicationConfig.class.php';
    include_once '../server/classes/arquitetura/log/Log.class.php';
            
    include_once '../server/classes/arquitetura/connection/Connection.class.php';
    include_once '../server/classes/arquitetura/connection/ConnectionFactory.class.php';
    
    $conn = ConnectionFactory::getBusinessConnection('nonna');
    $conn->open();
    
    $mysqli = $conn->getMysqli();
    $mysqli->autocommit(FALSE);
    
    $id = 140;
    $updateDate = '2014-06-28';
    
    $mysqli->query('SET @pId = ' . $id);
    $mysqli->query('SET @pUpdateDate = ' . $updateDate);
    
    $sql = 'call sCategoriaSalvar(?, @pId, @pUpdateDate)';
    
    $stmt = $mysqli->prepare($sql);
    $stmt->bind_param('s', $nome);
    $nome = 'Tiago';
    
    $stmt->execute();
    
    $results = $mysqli->query('SELECT @pId, @pUpdateDate');
    while ($row = $results->fetch_assoc()) {
        echo 'Id: ' . $row['@pId'] . '<br/>UpdateDate: ' . $row['@pUpdateDate'];
    }
    
    if($mysqli->errno) {
        die("Execution failed: ".$mysqli->errno.": ".$mysqli->error);
    }
    
    $mysqli->commit();
    $stmt->close();
    $conn->close();
?>

